package cn.gailvlun.gll.presentation.hotel.day

import android.support.v4.app.Fragment
import android.support.v4.app.FragmentManager
import android.support.v4.app.FragmentStatePagerAdapter
import android.view.ViewGroup
import cn.gailvlun.gll.net.hotel.InsomniaCategory


class HotelTemplatePagerAdapter(fm: FragmentManager?) : FragmentStatePagerAdapter(fm) {
    override fun getItem(position: Int): Fragment? {
        return when (position) {
            0 -> HotelTemplateFragment.newInstance(InsomniaCategory.S)
            1 -> HotelTemplateFragment.newInstance(InsomniaCategory.S)
            else -> {
                null
            }
        }
    }

    override fun getCount(): Int {
        return 2
    }

    private lateinit var mCurrentFragment: HotelTemplateFragment

    override fun setPrimaryItem(container: ViewGroup, position: Int, `object`: Any) {
        super.setPrimaryItem(container, position, `object`)
        mCurrentFragment = `object` as HotelTemplateFragment
    }

    fun getCurrentFragment(): HotelTemplateFragment {
        return mCurrentFragment
    }

}